988A - Diverse Team - CodeForces Solution


brute force implementation *800

Please click on ads to support us..

Python Code:

n, k = [int(x) for x in input().split()]
m = [int(y) for y in input().split()]

b = []
c = []
count = 0

for i in range(0, len(m)):
    if m[i] in b:
        count += 1
    else:
        count += 1
        b.append(m[i])
        c.append(count)

if(k > len(b)):
    print('NO')
else:
    print('YES')
    for j in range(0, k):
        print(c[j])

C++ Code:

#include<bits/stdc++.h>
main(){int k;std::map<int,int>m;for(int n=(std::cin>>n>>k,n),i=1;i<=n;i++)int a=(std::cin>>a,m[a]=i);
k*=m.size()>=k;puts(k?"YES":"NO");for(auto v:m)if(k-->0)std::cout<<v.second<<' ';puts("");}


Comments

Submit
0 Comments
More Questions

1354B - Ternary String
122B - Lucky Substring
266B - Queue at the School
1490A - Dense Array
1650B - DIV + MOD
1549B - Gregor and the Pawn Game
553A - Kyoya and Colored Balls
1364A - XXXXX
1499B - Binary Removals
1569C - Jury Meeting
108A - Palindromic Times
46A - Ball Game
114A - Cifera
776A - A Serial Killer
25B - Phone numbers
1633C - Kill the Monster
1611A - Make Even
1030B - Vasya and Cornfield
1631A - Min Max Swap
1296B - Food Buying
133A - HQ9+
1650D - Twist the Permutation
1209A - Paint the Numbers
1234A - Equalize Prices Again
1613A - Long Comparison
1624B - Make AP
660B - Seating On Bus
405A - Gravity Flip
499B - Lecture
709A - Juicer